package com.xdjk.networkdemo.base;

import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.view.WindowManager;

import com.xdjk.networkdemo.utils.ThemeUtile;

import butterknife.ButterKnife;
import me.yokeyword.fragmentation_swipeback.SwipeBackActivity;

public abstract class BaseActivity extends SwipeBackActivity {
    protected Context mContext;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        steepStatusBar();
        ThemeUtile.onActivityCreateSetTheme(this);
        setContentView(getContentViewId());
        ButterKnife.bind(this);
        this.mContext = this;
        Bundle bundle = getIntent().getExtras();
        initParms(bundle);
        initData();
        initViews();
        initListener();
    }

    /**
     * 获取化布局ID
     * @return
     */
    protected abstract int getContentViewId();
    /**
     * 初始化参数
     * @return
     */
    protected abstract void initParms(Bundle bundle);
    /**
     * 初始化数据
     * @return
     */
    protected abstract void initData();
    /**
     * 初始化视图
     * @return
     */
    protected abstract void initViews();
    /**
     * 初始化视图监听
     * @return
     */
    protected abstract void initListener();

    /**
     * 沉浸状态栏
     */
    private void steepStatusBar() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            // 透明状态栏
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            // 透明导航栏
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        }
    }

}
